<!DOCTYPE html>
[#assign ctx=springMacroRequestContext.contextPath/]
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>账户充值</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${ctx!}/statics/layui/css/layui.css" media="all">
    <script type="text/javascript" src="${ctx}/statics/layui/layui.js"></script>
    <script src="${ctx}/statics/js/jquery-3.6.0.js"></script>
    <script src="${ctx}/statics/js/jquery.qrcode.min.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
[#include "/common/headNav.html"]
[#include "/common/sideNav.html"]
    <div class="layui-body">
        <form class="layui-form" style="text-align: center;margin-top: 250px">
            <div class="layui-form-item" style="margin-top:10px;">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px">请输入您要充值的金额:</label>
                    <div class="layui-input-inline">
                        <input  type="number" value=0 oninput="limit(this)" id="moneyToPay" name="moneyToPay" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div>本网站目前支持的支付方式:</div>
                    <img src="${ctx}/statics/icon/alipay.jpg" width="50px" height="50px">
                    <button type="submit"  class="layui-btn" lay-submit lay-filter="form1">充值</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>

    function limit(obj){
        if(obj.value==""||obj.value==null){
            $('#moneyToPay')[0].value = 0;
        }
        else{
            $('#moneyToPay')[0].value = obj.value.replace(/\b(0+)/gi,"")
        }
    }

    layui.use(['layer','form'],function (){
        var form=layui.form;
        var layer = layui.layer;

        form.on('submit(form1)',function (data){
            var moneyToPay = data.field.moneyToPay;
            if (moneyToPay==0){
                layer.msg("充值金额不允许为0!",{icon:2});
                return false;
            }
            $.ajaxSetup({ async: false });
            $.post("/testPay", {moneyToPay:moneyToPay}, res=>{
                var id = window.open("","_blank");
                id.document.write(res);
            });
            return false;
        })
    })
</script>
</body>
</html>